<?
require_once("C_colorcycle.inc");

// Simulate database rows
$aDbResults = array(
	0 => array("Department 20","$15k"),
	1 => array("Department 20","$4k"),
	2 => array("Department 99","$36k"),
	3 => array("Department 01","$36k"),
	4 => array("Department 01","$21k"),
	5 => array("Department 01","$3k"),
	6 => array("Department 12","$0"),
	7 => array("Department 12","$101k"),
);

// ------------------------------------------------
$obj_lineColor = new ColorCycle();

print "<span style=\"color:green;font-style:oblique;\">Example shows simple default light green/white cycling<br />";
print '<div style="background-color:black">';
print "<table border=\"0\" align=\"center\" cellspacing=\"0\" width=\"100%\" style=\"margin:1px;\">\n";
print '<tr><th style="color:#FFF">Department</th><th style="color:#FFF">Value</th></tr>';
foreach( $aDbResults as $r ) {
	$bgcolor = $obj_lineColor->getColor();

	print " <tr bgcolor=\"$bgcolor\">\n";
	print "  <td>$r[0]</td>\n";
	print "  <td>$r[1]</td>\n";
	print " </tr>\n";
}
print "</table>\n";
print "</div>\n";
print "<br />\n\n";

// ------------------------------------------------
$cc = new ColorCycle(array("#EEFFEE","#FFFFFF","#EEEEEE"));
reset($aDbResults);

print "<span style=\"color:green;font-style:oblique;\">Example shows cycling with your own colors<br />";
print '<div style="background-color:black">';
print "<table border=\"0\" align=\"center\" cellspacing=\"0\" width=\"100%\" style=\"margin:1px;\">\n";
print '<tr><th style="color:#FFF">Department</th><th style="color:#FFF">Value</th></tr>';
foreach( $aDbResults as $r ) {
	$bgcolor = $cc->getColor();

	print " <tr bgcolor=\"$bgcolor\">\n";
	print "  <td>$r[0]</td>\n";
	print "  <td>$r[1]</td>\n";
	print " </tr>\n";
}
print "</table>\n";
print "</div>\n";
print "<br />\n\n";


// ------------------------------------------------
$cc2 = new ColorCycle();
reset($aDbResults);

print "<span style=\"color:green;font-style:oblique;\">Example shows sticky field (Department) not repeating and sticky background color staying with sticky field block<br />";
print '<div style="background-color:black">';
print "<table border=\"0\" align=\"center\" cellspacing=\"0\" width=\"100%\" style=\"margin:1px;\">\n";
print '<tr><th style="color:#FFF">Department</th><th style="color:#FFF">Value</th></tr>';
foreach( $aDbResults as $r ) {
	$bgcolor     = $cc2->getStickyColor($r[0]);
	$stickyField = $cc2->getStickyFieldIfChanged();

	print " <tr bgcolor=\"$bgcolor\">\n";
	print "  <td>$stickyField</td>\n";
	print "  <td>$r[1]</td>\n";
	print " </tr>\n";
}
print "</table>\n";
print "</div>\n";
print "<br />\n\n";

?>
